﻿using MahApps.Metro.Controls;
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;

namespace FolderTag.ExtendView.Tools
{
    /// <summary>
    /// ToolsMainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class ToolsMainWindow : MetroWindow
    {
        Regex _Regex = new Regex(@"[\{,\},\],\[]");//Base64过滤异常字符

        public ToolsMainWindow()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Base64_Encrypt_Button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(Base64_Encrypt_TextBox.Text))
                Base64_Decrypt_TextBox.Text = Convert.ToBase64String(Encoding.UTF8.GetBytes(Base64_Encrypt_TextBox.Text));
            else {
                var decrypt = _Regex.Replace(Base64_Decrypt_TextBox.Text, "");
                Base64_Encrypt_TextBox.Text = Encoding.UTF8.GetString(Convert.FromBase64String(decrypt));
            }
        }
    }
}
